<?php

/* 
 * 生成数据表格
 * allenleong
 */

namespace Admin\Controller;
use Think\Controller;

class BuildController extends Controller{
    
    private $title; //标题
    private $_data_list = array(); //数据列表
    private $_field_list=array(); //表格标题字段
    private $_buildtemptel;//输出模板
    
    /*
     * 设置标题
     */
    public function title($title)
    {
        $this->title = $title;
        return $this;
    }        
    
    /*
     *设置列表数据 
    */
    public function datalist($data_list){
        
        $this->_data_list = $data_list;
        return $this;
    }
    
    /*
     * 设置表格标题
     */
    public function addfield($title,$name){
        
        $key = array('name'=>$name,'title'=>$title);
        $this->_field_list[] = $key;
        return $this;
        
    }
    
    /*
     * 设置模板
     */
    public function buildtemptel($temptel){
        
        $this->_buildtemptel = $temptel;
        return $this;
        
    }
    
    /*
     * 渲染模板
     */
    public function show() {
       
         dump($this->_field_list);
         $this->assign('list',$this->_data_list['data']);
         $this->assign('_page',$this->data_list['_page']);
         parent::display($this->_buildtemptel);
    }
}